from flask import Flask
from flask_wechat import filters, WeChat

app = Flask(__name__)

wechat = WeChat(app)

@wechat.account
def get_config(id):
    return dict(
        appid="appid",
        appsecret="appsecret",
        token="token"
    ) if id=="demo" else dict()

@wechat.handler("demo", filters.event.subscribe)
def subscribe(message):
    return message.reply_text("Thank you for subscribe!")

@wechat.handler("demo")
def all(message):
    return message.reply_text("I'm confused...")

@wechat.handler("demo", filters.message.startswith("hello"))
def hello(message):
    return message.reply_text("world")

if __name__ == "__main__":
    app.run()